Vue.filter('money',function(val){
  return (val/100).toFixed(2)
})
let vm = new Vue({
  el:'#app',
  data:{
    name:"66",
    list:[]
  },
  created() {
    this.getData()
  },
  methods: {
    getData(){
      fetch('./data.json').then(res=>res.json()).then(data=>{
        console.log(data)
        this.list = data
      })
    },
    del(item){
      this.list = this.list.filter(val=>{
        return val.id !== item.id
      })
    },
    clear(){
      this.list = [];
    }
  },
  computed: {
    total(){
      return this.list.reduce((prev,cur)=>{
        if(cur.isSelect){
          return prev + cur.price*cur.count
        }else{
          return prev
        }
      },0)
    },
    // all(){
    //   return this.list.every(item=>item.isSelect)
    // }
    all:{
      get(){
        return this.list.every(item=>item.isSelect)
      },
      set(val){
        this.list.forEach(item=>{
          item.isSelect = val;
        })
      }
    }
  },
})